/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.HeurCommitException;
/*   4:    */ import com.atomikos.icatch.HeurHazardException;
/*   5:    */ import com.atomikos.icatch.HeurMixedException;
/*   6:    */ import com.atomikos.icatch.HeurRollbackException;
/*   7:    */ import com.atomikos.icatch.HeuristicMessage;
/*   8:    */ import com.atomikos.icatch.RollbackException;
/*   9:    */ import com.atomikos.icatch.SysException;
/*  10:    */ import com.atomikos.icatch.TxState;
/*  11:    */ import com.atomikos.icatch.admin.AdminTransaction;
/*  12:    */ import java.util.Stack;
/*  13:    */ 
/*  14:    */ class AdminTransactionImp
/*  15:    */   implements AdminTransaction
/*  16:    */ {
/*  17:    */   private CoordinatorImp coord_;
/*  18:    */   
/*  19:    */   static int convertState(Object state)
/*  20:    */   {
/*  21: 62 */     int ret = -1;
/*  22: 64 */     if (state.equals(TxState.ACTIVE)) {
/*  23: 65 */       ret = -3;
/*  24: 66 */     } else if (state.equals(TxState.PREPARING)) {
/*  25: 67 */       ret = -2;
/*  26: 68 */     } else if (state.equals(TxState.IN_DOUBT)) {
/*  27: 69 */       ret = 0;
/*  28: 70 */     } else if (state.equals(TxState.HEUR_MIXED)) {
/*  29: 71 */       ret = 4;
/*  30: 72 */     } else if (state.equals(TxState.HEUR_HAZARD)) {
/*  31: 73 */       ret = 3;
/*  32: 74 */     } else if (state.equals(TxState.HEUR_COMMITTED)) {
/*  33: 75 */       ret = 1;
/*  34: 76 */     } else if (state.equals(TxState.HEUR_ABORTED)) {
/*  35: 77 */       ret = 2;
/*  36: 78 */     } else if (state.equals(TxState.COMMITTING)) {
/*  37: 79 */       ret = 6;
/*  38: 80 */     } else if (state.equals(TxState.ABORTING)) {
/*  39: 81 */       ret = 5;
/*  40: 82 */     } else if (state.equals(TxState.TERMINATED)) {
/*  41: 83 */       ret = 7;
/*  42:    */     }
/*  43: 85 */     return ret;
/*  44:    */   }
/*  45:    */   
/*  46:    */   static Object convertState(int state)
/*  47:    */   {
/*  48: 98 */     Object ret = null;
/*  49:100 */     switch (state)
/*  50:    */     {
/*  51:    */     case 0: 
/*  52:102 */       ret = TxState.IN_DOUBT;
/*  53:103 */       break;
/*  54:    */     case 4: 
/*  55:105 */       ret = TxState.HEUR_MIXED;
/*  56:106 */       break;
/*  57:    */     case 3: 
/*  58:108 */       ret = TxState.HEUR_HAZARD;
/*  59:109 */       break;
/*  60:    */     case 1: 
/*  61:111 */       ret = TxState.HEUR_COMMITTED;
/*  62:112 */       break;
/*  63:    */     case 2: 
/*  64:114 */       ret = TxState.HEUR_ABORTED;
/*  65:115 */       break;
/*  66:    */     case 6: 
/*  67:117 */       ret = TxState.COMMITTING;
/*  68:118 */       break;
/*  69:    */     case 5: 
/*  70:120 */       ret = TxState.ABORTING;
/*  71:121 */       break;
/*  72:    */     case 7: 
/*  73:123 */       ret = TxState.TERMINATED;
/*  74:124 */       break;
/*  75:    */     }
/*  76:130 */     return ret;
/*  77:    */   }
/*  78:    */   
/*  79:    */   AdminTransactionImp(CoordinatorImp coord)
/*  80:    */   {
/*  81:142 */     this.coord_ = coord;
/*  82:    */   }
/*  83:    */   
/*  84:    */   public String getTid()
/*  85:    */   {
/*  86:151 */     return this.coord_.getCoordinatorId();
/*  87:    */   }
/*  88:    */   
/*  89:    */   public boolean wasCommitted()
/*  90:    */   {
/*  91:160 */     return this.coord_.isCommitted();
/*  92:    */   }
/*  93:    */   
/*  94:    */   public int getState()
/*  95:    */   {
/*  96:169 */     Object state = this.coord_.getState();
/*  97:    */     
/*  98:171 */     return convertState(state);
/*  99:    */   }
/* 100:    */   
/* 101:    */   public HeuristicMessage[] getTags()
/* 102:    */   {
/* 103:180 */     return this.coord_.getTags();
/* 104:    */   }
/* 105:    */   
/* 106:    */   public HeuristicMessage[] getHeuristicMessages()
/* 107:    */   {
/* 108:189 */     return this.coord_.getHeuristicMessages();
/* 109:    */   }
/* 110:    */   
/* 111:    */   public HeuristicMessage[] getHeuristicMessages(int state)
/* 112:    */   {
/* 113:198 */     HeuristicMessage[] ret = null;
/* 114:199 */     Object txstate = convertState(state);
/* 115:200 */     if (txstate != null) {
/* 116:201 */       ret = this.coord_.getHeuristicMessages(txstate);
/* 117:    */     }
/* 118:204 */     return ret;
/* 119:    */   }
/* 120:    */   
/* 121:    */   public void forceCommit()
/* 122:    */     throws HeurRollbackException, HeurHazardException, HeurMixedException, SysException
/* 123:    */   {
/* 124:    */     try
/* 125:    */     {
/* 126:215 */       this.coord_.commitHeuristically();
/* 127:    */     }
/* 128:    */     catch (RollbackException rb)
/* 129:    */     {
/* 130:219 */       Stack errors = new Stack();
/* 131:220 */       errors.push(rb);
/* 132:221 */       throw new SysException("Error in forced commit: " + rb.getMessage(), errors);
/* 133:    */     }
/* 134:    */   }
/* 135:    */   
/* 136:    */   public void forceRollback()
/* 137:    */     throws HeurCommitException, HeurMixedException, HeurHazardException, SysException
/* 138:    */   {
/* 139:233 */     this.coord_.rollbackHeuristically();
/* 140:    */   }
/* 141:    */   
/* 142:    */   public void forceForget()
/* 143:    */   {
/* 144:242 */     this.coord_.forget();
/* 145:    */   }
/* 146:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.AdminTransactionImp
 * JD-Core Version:    0.7.0.1
 */